<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SupplierStoreGoodsAmount extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('supplier_store_goods_amount', ['comment' => '供应商门店商品金额表'])
             ->addColumn('company_id', 'integer', ['limit' => 11, 'default' => 0, "after" => 'id', 'comment' => '公司ID'])
             ->addColumn('supplier_id', 'integer', ['limit' => 11, 'default' => 0, "after" => 'company_id', 'comment' => '供应商ID'])
             ->addColumn('goods_id', 'integer', ['limit' => 11, 'default' => 0, "after" => 'supplier_id', 'comment' => '商品ID'])
             ->addColumn('goods_rule_id', 'integer', ['limit' => 11, 'default' => 0, "after" => 'goods_id', 'comment' => '商品规格ID'])
             ->addColumn('type', 'integer', ['limit' => 1, 'default' => 1, "after" => 'goods_rule_id', 'comment' => '类型:1=金额,2=数量'])
             ->addColumn('num', 'integer', ['limit' => 11, 'default' => 0, "after" => 'type', 'comment' => '数量'])
             ->addColumn('money', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0, "after" => 'num', 'comment' => '余额'])
             ->addColumn('original_money', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0, "after" => 'money', 'comment' => '充值金额'])
             ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'after' => 'original_money', 'comment' => '1:正常,2:禁用'])
             ->addColumn('create_time', 'integer', ['limit' => 10, 'after' => 'status', 'default' => 0, 'comment' => '创建时间'])
             ->addColumn('update_time', 'integer', ['limit' => 10, 'after' => 'create_time', 'default' => 0, 'comment' => '更新时间'])
             ->addColumn('delete_time', 'integer', ['limit' => 10, 'after' => 'update_time', 'default' => 0, 'comment' => '删除时间'])
             ->create();
    }
}
